<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        var xhr = new XMLHttpRequest();
        xhr.open('GET','http://127.0.0.1/AJAX_project/ajax_http.php');
        // 设置请求头
        xhr.setRequestHeader('Foo','Bar');
        // 一旦你的请求体是 urlencoded 格式的内容 一定要设置请求头中 Content-Type','application/x-www-form-urlencoded
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        // 以urlencoded 格式设置请求体
        xhr.send('key1=value1&key2=value2');
    </script>
</head>
<body>

    
</body>
</html>